{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3393
  Verdict: Accepted
}
var s:string; r,b,c,i,k:int64;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
readln(s);
k:=length(s);
r:=(k+2)*(k+1) div 2;
b:=0;
c:=0;
i:=1;
while i<=k do begin
    inc(C);
    if s[i]='(' then inc(b) else dec(b);
    if b=0 then begin
       inc(r,c*(c-1) div 2);
       c:=0;
    end;
    inc(i);
end;
write(r);
end.